package controller;

import java.awt.Container;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JLabel;
import javax.swing.SwingUtilities;

import controller.GUICreateCustomerViewController;
import controller.GUICreateReservationController;
import controller.GUICreateRoomViewController;
import controller.GuiRoomsListController;
import controller.billing.GuiCreateBillViewController;


import view.MainWindow;

public class GUIMainWindowController implements ActionListener
{
	private MainWindow inst;
	private Container cont;
	
	public GUIMainWindowController(){
		this.inst= new MainWindow();
		inst.setLocationRelativeTo(null);
		inst.setVisible(true);
		this.cont = inst.getContentPane();
		
		inst.addActionsListeners(this);
		
	}
	

	@Override
	public void actionPerformed(ActionEvent e)
	{
			if(e.getSource()==this.inst.getExitMenuItem()){
				System.exit(0);
			}else if(e.getSource()==this.inst.getEditCustomerMenuItem()){
				cont.removeAll();
				this.cont = this.inst.getContentPane();
				GuiCustomersListController controller = new GuiCustomersListController(this.cont);
				cont.add(controller.getCustomersView());
				cont.setSize(controller.getCustomersView().getSize());
				cont.validate();
				cont.repaint();
			}else if(e.getSource()==this.inst.getCreateCustomerMenuItem()){
				cont.removeAll();
				this.cont = this.inst.getContentPane();
			    GUICreateCustomerViewController controller = new GUICreateCustomerViewController();
			    cont.add(controller.getCustomerView());
			    cont.setSize(controller.getCustomerView().getSize());
				cont.validate();
				cont.repaint();
			}else if(e.getSource() == this.inst.getCreateRoomMenuItem()){
				cont.removeAll();
				this.cont = this.inst.getContentPane();
			    GUICreateRoomViewController controller = new GUICreateRoomViewController();
				cont.add(controller.getRoomView());
				cont.setSize(controller.getRoomView().getSize());
				cont.validate();
				cont.repaint();
			}else if(e.getSource() == this.inst.getEditRoomsMenuItem()){
				cont.removeAll();
				this.cont = this.inst.getContentPane();
			    GuiRoomsListController controller = new GuiRoomsListController(this.cont);
				cont.add(controller.getRoomsView());
				cont.setSize(controller.getRoomsView().getSize());
				cont.validate();
				cont.repaint();
			}else if(e.getSource() == this.inst.getCreateReservationMenuItem()){
				cont.removeAll();
				this.cont = this.inst.getContentPane();
			    GUICreateReservationController controller = new GUICreateReservationController();
				cont.add(controller.getView());
				System.out.println("size:" + controller.getView().getSize());
				//cont.setSize(controller.getView().getSize());
				cont.validate();
				cont.repaint();
			}
			else if(e.getSource() == this.inst.getCreateBillMenuItem()){
				cont.removeAll();
				this.cont = this.inst.getContentPane();
			    GuiCreateBillViewController controller = new GuiCreateBillViewController();
				cont.add(controller.getView());
				
				//cont.setSize(controller.getView().getSize());
				cont.validate();
				cont.repaint();
			}
	}
}
